﻿using System.Data.Entity;
using System;

namespace TraceThisItem.Domain.Initializers
{
	/// <summary>
	/// Esta clase sobreescribe el método Seed, el cual sirve para guardar algunos datos iniciales en el modelo que acaba de ser re-creado.
	/// </summary>
	public class DropCreateAndSeedDatabaseIfModelChanges : DropCreateDatabaseIfModelChanges<PersistenceManager>
	{
		protected override void Seed(PersistenceManager context)
		{
			#region Carga de Usuarios Demo

			var userPablo = new User
			{
				Firstname = "Pablo",
				Lastname = "Carballo",
				UserName = "pcarballo",
			};

			var userHernan = new User
			{
				Firstname = "Hernán",
				Lastname = "Zbucki",
				UserName = "hezbu",
			};

			context.Users.Add(userPablo);
			context.Users.Add(userHernan);

			#endregion Carga de Usuarios Demo

			#region Carga de Proyectos Demo

			var project1 = new Project
			{
				Name = "Forúnculo S.A.",
				OwnerUserName = "pcarballo",
				CreatedOn = DateTime.Now
			};

			var project2 = new Project
			{
				Name = "Proyecto MOSCA",
				OwnerUserName = "hezbu",
				CreatedOn = DateTime.Now
			};

			context.Projects.Add(project1);
			context.Projects.Add(project2);

			#endregion Carga de Proyectos Demo

			var team1 = new Team
			{
				Name = "Grosos"
			};

			team1.Users.Add(userHernan);
			team1.Users.Add(userPablo);

			project1.Teams.Add(team1);

			/*var itemTypeBug = new ItemType
			{
				Name = "Bug",
                CurrentProject = project
			};
			context.ItemTypes.Add(itemTypeBug);

            #region Carga de Status Types Demo

            var statusTypeNuevo = new StatusType
                {
                    Name = "Nuevo",
                    Project = project
                };
            context.StatusTypes.Add(statusTypeNuevo);

            context.StatusTypes.Add(new StatusType
            {
                Name = "Asignado",
                Project = project
            });

            context.StatusTypes.Add(new StatusType
            {
                Name = "Se necesitan más datos",
                Project = project
            });

            context.StatusTypes.Add(new StatusType
            {
                Name = "Resuelto",
                Project = project
            });

            context.StatusTypes.Add(new StatusType
            {
                Name = "Cerrado",
                Project = project
            });

            #endregion Carga de Status Types Demo

			context.Items.Add(new Item
			{
				CreatedOn = DateTime.Now,
				CurrentStatus = statusTypeNuevo,
				Description = "Error muy feo",
				LatestUpdate = DateTime.Now,
				Priority = (byte)ItemPriority.Alta,
				Project = project,
				Responsible = userPablo,
				Team = teamGrosos,
				Type = itemTypeBug
			});

			context.Items.Add(new Item
			{
				CreatedOn = DateTime.Now,
				CurrentStatus = statusTypeNuevo,
				Description = "Otro error muy feo",
				LatestUpdate = DateTime.Now,
				Priority = (byte)ItemPriority.Alta,
				Project = project,
				Responsible = userPablo,
				Team = teamGrosos,
				Type = itemTypeBug
			});*/
		}
	}

  
}